/* eslint-disable @typescript-eslint/no-var-requires */
const qiniu = require('qiniu');

const accessKey = '0QsMJEN7nugQgZlegJeN9xnN5jlLdS_I2yJW2qRE';
const secretKey = 'jWa0qKsuXC7MUPgw6OKfNz0BWrar8NLYwt3k3Q75';
const mac = new qiniu.auth.digest.Mac(accessKey, secretKey);

// 通过腾讯云机器人获取对话文字
export async function getToken(ctx: Context, next: Next): Promise<void> {


  try {
    const options = {
      scope: 'photostate',
    };
    const putPolicy = new qiniu.rs.PutPolicy(options);
    const uploadToken = putPolicy.uploadToken(mac);
    console.log(uploadToken, '.....')
    ctx.api.success(uploadToken, 'success');
  } catch (error) {
    ctx.api.fail(-1, error);
  }
  
  return next();
}
